package io.renren.modules.clothingtype.controller;

import io.renren.common.utils.Result;
import io.renren.common.utils.SubjectNestedVO;
import io.renren.modules.clothingtype.dto.ClothingTypeDTO;
import io.renren.modules.clothingtype.service.ClothingTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * 服装类型表
 */
@RestController
@RequestMapping("clothingtype")
@Api(tags="服装类型表")
public class ClothingTypeController {

    @Autowired
    private ClothingTypeService clothingTypeService;

    @ApiOperation("服装类型列表展示")
    @GetMapping("typepage")
    public Result<List<SubjectNestedVO>> typePage(@RequestParam Map<String, Object> params) {
        List<SubjectNestedVO> pageData = clothingTypeService.typePage(params);
        return new Result<List<SubjectNestedVO>>().ok(pageData);
    }

    @ApiOperation("服装类型添加")
    @PostMapping("add")
    public Result<Map<String,Object>> addClothingType(@RequestBody ClothingTypeDTO dto) {
        clothingTypeService.addClothingType(dto);
        return new Result<Map<String, Object>>();
    }

    @ApiOperation("服装类型修改")
    @PostMapping("change")
    public Result<Map<String,Object>> changeClothingType(@RequestBody ClothingTypeDTO dto) {
        clothingTypeService.changeClothingType(dto);
        return new Result<Map<String, Object>>();
    }

    @ApiOperation("服装类型删除")
    @DeleteMapping("{ids}")
    public Result<Map<String,Object>> deleteClothingType(@PathVariable List<Long> ids) {
        clothingTypeService.deleteClothingType(ids);
        return new Result<Map<String, Object>>();
    }
}
